package com.qf.service.Imp;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.AirMapper;
import com.qf.pojo.AirQualityIndex;
import com.qf.service.AirService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AirServiceImpl implements AirService {

    @Autowired
    AirMapper airMapper;

    @Override
    public PageInfo<AirQualityIndex> pageInfo(String name, Integer page, Integer size) {

        PageHelper.startPage(page,size );
        List<AirQualityIndex> airList = airMapper.airList(name);
        PageInfo<AirQualityIndex> pageInfo=new PageInfo<>(airList);
        return pageInfo;
    }

    @Override
    public Integer save(AirQualityIndex airQualityIndex) {
        return airMapper.insertSelective(airQualityIndex);
    }

    @Override
    public AirQualityIndex findById(Integer id) {
        return airMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer update(AirQualityIndex airQualityIndex) {
        return airMapper.updateByPrimaryKeySelective(airQualityIndex);
    }

    @Override
    public Integer deleteById(Integer id) {
//        AirQualityIndex airQualityIndex=new AirQualityIndex();
//        airQualityIndex.setId(id);
//        return airMapper.delete(airQualityIndex);
        return airMapper.deleteByPrimaryKey(id);
    }


}
